package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.organization.RCSupplier;
import com.shrct.businessprocess.organization.impl.RCSupplierImpl;
import com.shrct.businessprocess.project.RCRealMoney;
import com.shrct.businessprocess.purchase.RCBasePurchaseRequest;
import com.shrct.businessprocess.purchase.RCSupplierPriceQuery;
import com.shrct.businessprocess.purchase.impl.RCBasePurchaseRequestImpl;
import com.shrct.businessprocess.purchase.proxy.RCSupplierPriceQueryProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCSUPPLIERPRICEQUERY_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcsupplierpricequery")
public class RCSupplierPriceQueryImpl extends BaseModelObject implements RCSupplierPriceQuery {
  public RCSupplierPriceQueryImpl() {
    super();
  }
  
  public RCSupplierPriceQueryImpl(final RCBasePurchaseRequest purchaseRequest) {
    super();
    this.purchaseRequest = purchaseRequest;
  }
  
  @JoinColumn(name = "purchaseRequest_id")
  @ManyToOne(targetEntity = RCBasePurchaseRequestImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCBasePurchaseRequest purchaseRequest;
  
  public RCBasePurchaseRequest getPurchaseRequest() {
    return this.purchaseRequest;
  }
  
  public RCSupplierPriceQuery setPurchaseRequest(final RCBasePurchaseRequest purchaseRequest) {
    this.purchaseRequest = purchaseRequest;
    return this;			
    
  }
  
  @JoinColumn(name = "supplier_id")
  @ManyToOne(targetEntity = RCSupplierImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCSupplier supplier;
  
  public RCSupplier getSupplier() {
    return this.supplier;
  }
  
  public RCSupplierPriceQuery setSupplier(final RCSupplier supplier) {
    this.supplier = supplier;
    return this;			
    
  }
  
  private Date queryDate;
  
  public Date getQueryDate() {
    return this.queryDate;
  }
  
  public RCSupplierPriceQuery setQueryDate(final Date queryDate) {
    this.queryDate = queryDate;
    return this;			
    
  }
  
  @Embedded
  @AttributeOverrides(value = { @AttributeOverride(name = "amount", column = @Column(name = "totalPrice_amount") ), @AttributeOverride(name = "exchangeRate", column = @Column(name = "totalPrice_exchangeRate") ), @AttributeOverride(name = "workaround", column = @Column(name = "totalPrice_workaround") ) } )
  @AssociationOverrides(value = @AssociationOverride(name = "currencyType", joinColumns = @JoinColumn(name = "totalPrice_currencyType") ) )
  private RCRealMoney totalPrice = com.shrct.businessprocess.project.RCRealMoney.create();
  
  public RCRealMoney getTotalPrice() {
    return this.totalPrice;
  }
  
  public RCSupplierPriceQuery setTotalPrice(final RCRealMoney totalPrice) {
    this.totalPrice = totalPrice;
    return this;			
    
  }
  
  private Date deliveryDate;
  
  public Date getDeliveryDate() {
    return this.deliveryDate;
  }
  
  public RCSupplierPriceQuery setDeliveryDate(final Date deliveryDate) {
    this.deliveryDate = deliveryDate;
    return this;			
    
  }
  
  private Integer term;
  
  public Integer getTerm() {
    return this.term;
  }
  
  public RCSupplierPriceQuery setTerm(final Integer term) {
    this.term = term;
    return this;			
    
  }
  
  private String comment;
  
  public String getComment() {
    return this.comment;
  }
  
  public RCSupplierPriceQuery setComment(final String comment) {
    this.comment = comment;
    return this;			
    
  }
  
  public static RCSupplierPriceQuery create(final RCBasePurchaseRequest purchaseRequest, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.purchase.RCSupplierPriceQuery rCSupplierPriceQuery = new com.shrct.businessprocess.purchase.impl.RCSupplierPriceQueryImpl(
    	purchaseRequest
    );
    objectFactory.create(rCSupplierPriceQuery);
    return rCSupplierPriceQuery;			
    
  }
  
  public static RCSupplierPriceQuery createRCSupplierPriceQueryImpl(final RCBasePurchaseRequest purchaseRequest, final IObjectFactory objectFactory, final Procedure1<RCSupplierPriceQuery> init) {
    com.shrct.businessprocess.purchase.RCSupplierPriceQuery rCSupplierPriceQuery = new com.shrct.businessprocess.purchase.impl.RCSupplierPriceQueryImpl(
    	purchaseRequest
    );
    objectFactory.create(rCSupplierPriceQuery);
    init.apply(rCSupplierPriceQuery);
    
    return rCSupplierPriceQuery;			
    
  }
  
  public RCSupplierPriceQueryProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCSupplierPriceQueryProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCSupplierPriceQueryProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
